﻿<!DOCTYPE html>
<!--试题生成-->
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>
    <script src="/static/js/FileSaver.js"></script>
    <script src="/static/js/jquery.wordexport.js"></script>
    <style>
        .el-input__suffix {
            right: initial !important;
        }
    </style>
    <style>
        .el-table__body-wrapper table tbody tr td {
            text-align: center;
        }

        .el-table .cell {
            text-align: center;
        }
    </style>
</head>
<body>
    
    <div id="app" v-cloak>
        <el-form label-position="right" :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="100px"
                 size="mini">

            <el-row type="flex" justify="end">
                <el-form-item>
                    <el-button type="primary" @click="onShow()">配置试卷</el-button>  <!--<el-button type="primary" @click="UserInput('tj')">选择答题人</el-button>--> <el-button type="primary" @click="onExamQuestions">生成试卷</el-button> <el-button type="primary" @click="onWord">生成Word</el-button>
                </el-form-item>
                <!--<el-form-item>
            <el-button type="primary" @click="onBack">在线提交</el-button>
        </el-form-item>-->

            </el-row>
            <div id="showExamQuestions" title="试题生成配置" v-if="showExamQuestions">
                <el-row>
                    <el-col :span="11">
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{"培训课件"+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.cbsCourseId" slot="suffix"
                                               :placeholder="TrainingRecord.TrainingCoursewareName">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in TrainingCoursewareName" :label="item.trainingCoursewareName"
                                                   :value="item.id">
                                        </el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                    <el-col :span="11" :offset="2">
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input type="text" v-model="Form.testNo" autocomplete="off" size="mini">
                                    <template slot="prepend">
                                        <div> {{"试题编号"+mark.m}}</div>
                                    </template>

                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>

                <el-row>
                    <el-col :span="11">
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{"难易程度"+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.degreeOfDifficulty" slot="suffix"
                                               :placeholder="TestQuestions.DegreeOfDifficulty">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in DegreeOfDifficultyList" :label="item.value"
                                                   :value="item.key">
                                        </el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>

                    <el-col :span="11" :offset="2">
                        <el-form-item>
                            <div class="elst-select-mini">
                                <el-input size="mini">
                                    <template slot="prepend">
                                        {{"考核日期"+mark.m}}
                                    </template>
                                    <el-date-picker slot="suffix" v-model="Form.examinationDate" type="date" size="mini"
                                                    format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择时间">
                                    </el-date-picker>
                                </el-input>
                            </div>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="11">
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input type="text" v-model="Form.judgmentNumber" autocomplete="off" size="mini">
                                    <template slot="prepend">
                                        <div> {{"判断题数"+mark.m}}</div>
                                    </template>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                    <el-col :span="11" :offset="2">
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input type="text" v-model="Form.judgmentScore" autocomplete="off" size="mini">
                                    <template slot="prepend">
                                        <div> {{"判断每题分数"+mark.m}}</div>
                                    </template>

                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="11">
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input type="text" v-model="Form.singleNumber" autocomplete="off" size="mini">
                                    <template slot="prepend">
                                        <div> {{"单选题数"+mark.m}}</div>
                                    </template>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                    <el-col :span="11" :offset="2">
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input type="text" v-model="Form.singleScore" autocomplete="off" size="mini">
                                    <template slot="prepend">
                                        <div> {{"单选每题分数"+mark.m}}</div>
                                    </template>

                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="11">
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input type="text" v-model="Form.multipleNumber" autocomplete="off" size="mini">
                                    <template slot="prepend">
                                        <div> {{"多选题数"+mark.m}}</div>
                                    </template>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                    <el-col :span="11" :offset="2">
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input type="text" v-model="Form.multipleScore" autocomplete="off" size="mini">
                                    <template slot="prepend">
                                        <div> {{"多选每题分数"+mark.m}}</div>
                                    </template>

                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div class="elst-select-mini">
                            <el-form-item>
                                <div class="el-input--mini el-input-group">
                                    <div class="el-input-group__prepend">
                                        {{"备注"+mark.m}}
                                    </div>
                                    <el-input class="el-textarea__inner" type="textarea"
                                              v-model="Form.remarks" autocomplete="off"></el-input>
                                </div>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
            </div>

            <div id="export_word">
                <div v-if="showExamQuestions2" title="试题生成配置" style="width:595px;">
                    <h3>{{Form2.title}}</h3>
                    <table cellspacing="0" cellpadding="0" border="0" class="el-table__header" style="width: 594px;">
                        <tr><td>{{"培训课件"+mark.m}}</td><td>{{Form2.cbsCourseId}}</td><td>{{"试题编号"+mark.m}}</td><td>{{Form2.testNo}}</td></tr>
                        <tr><td>{{"难易程度"+mark.m}}</td><td>{{Form2.degreeOfDifficulty}}</td><td>{{"考核日期"+mark.m}}</td><td>{{Form2.examinationDate}}</td></tr>
                        <tr><td>{{"判断题数"+mark.m}}</td><td>{{Form2.judgmentNumber}}</td><td>{{"判断每题分数"+mark.m}}</td><td>{{Form2.judgmentScore}}</td></tr>
                        <tr><td>{{"单选题数"+mark.m}}</td><td>{{Form2.singleNumber}}</td><td>{{"单选每题分数"+mark.m}}</td><td>{{Form2.singleScore}}</td></tr>
                        <tr><td>{{"多选题数"+mark.m}}</td><td>{{Form2.multipleNumber}}</td><td>{{"多选每题分数"+mark.m}}</td><td>{{Form2.multipleScore}}</td></tr>
                        <tr><td>{{"备注"+mark.m}}</td><td colspan="3">{{Form2.remarks}}</td></tr>
                    </table>
                    <br>
                    <!--<el-row>
                        <el-col :span="11">
                            <p class="main-label">{{"培训课件"+mark.m}}</p>
                            <p class="lh35">{{Form2.cbsCourseId}}</p>
                        </el-col>
                        <el-col :span="11" :offset="2">
                            <p class="main-label">{{"试题编号"+mark.m}}</p>
                            <p class="lh35">{{Form2.testNo}}</p>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="11">
                            <p class="main-label">{{"难易程度"+mark.m}}</p>
                            <p class="lh35">{{Form2.degreeOfDifficulty}}</p>
                        </el-col>
                        <el-col :span="11" :offset="2">
                            <p class="main-label">{{"考核日期"+mark.m}}</p>
                            <p class="lh35">{{Form2.examinationDate}}</p>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="11">
                            <p class="main-label">{{"判断题数"+mark.m}}</p>
                            <p class="lh35">{{Form2.judgmentNumber}}</p>
                        </el-col>
                        <el-col :span="11" :offset="2">
                            <p class="main-label">{{"判断每题分数"+mark.m}}</p>
                            <p class="lh35">{{Form2.judgmentScore}}</p>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="11">
                            <p class="main-label">{{"单选题数"+mark.m}}</p>
                            <p class="lh35">{{Form2.singleNumber}}</p>
                        </el-col>
                        <el-col :span="11" :offset="2">
                            <p class="main-label">{{"单选每题分数"+mark.m}}</p>
                            <p class="lh35">{{Form2.singleScore}}</p>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="11">
                            <p class="main-label">{{"多选题数"+mark.m}}</p>
                            <p class="lh35">{{Form2.multipleNumber}}</p>
                        </el-col>
                        <el-col :span="11" :offset="2">
                            <p class="main-label">{{"多选每题分数"+mark.m}}</p>
                            <p class="lh35">{{Form2.multipleScore}}</p>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="24">
                            <p class="main-label">{{"备注"+mark.m}}</p>
                            <p class="lh35">{{Form2.remarks}}</p>
                        </el-col>
                    </el-row>-->
                </div>
                <div v-for="(todo,index) in TrainingCoursewareNameList">
                    <el-row>
                        <el-col :span="24"> {{index+1}} {{todo.cbS_Questions.testQuestionsContent}}&nbsp;&nbsp;{{todo.cbS_Questions.testQuestionsType}}</el-col>
                    </el-row>
                    <br />
                    <el-row>
                        <div v-for="answer in todo.cbS_Questions.cbS_QuestionsOptions">
                            <el-col :span="12">   <el-checkbox></el-checkbox> {{answer.optionName+":"+answer.optionComment}}</el-col>
                        </div>
                    </el-row>
                    <br />

                </div>
                <el-table v-if="showExamQuestions2" stripe ref="table" :data="TrainingCoursewareNameList" :height="ListItem.tableHeight" border
                          row-style="height:10px" style="width:595px;">
                    <el-table-column type="index" :label="ContractorDirectory.SerialNumber" :index="indexMethod" width="50"
                                     show-overflow-tooltip="true"></el-table-column>

                    <el-table-column prop="cbS_Questions.testQuestionsContent" label="试题内容"
                                     show-overflow-tooltip="true">
                    </el-table-column>
                    <el-table-column prop="cbS_Questions.testQuestionsType" label="试题类型">
                    </el-table-column>
                    <el-table-column prop="cbS_Questions.mark01"
                                     label="答案" show-overflow-tooltip="true">
                    </el-table-column>


                </el-table>
               
            </div>
        </el-form>
        <!-- <div style="width:100% ">
        <label>{{TrainingCoursewareName}}课件考试试题</label>
        <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;难易程度-一般</label>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <el-button type="primary" @click="onDelete">{{col.btnPrint}} </el-button>
    </div>

    <div v-for="todo in TrainingCoursewareNameList">
        <el-row>
            <el-col :span="24"> {{todo.key+1}} {{todo.value}}&nbsp;&nbsp;{{todo.AnswerType}}</el-col>
        </el-row>
        <br />
        <el-row>
            <div v-for="answer in todo.answer">
                <el-col :span="12">   <el-checkbox ></el-checkbox> {{answer}}</el-col>
            </div>
        </el-row>
        <br />
    </div>
    {{answerPeople}}
    <el-form :inline="true">
        <el-row type="flex" justify="end">
            <el-form-item>
                <el-button type="primary" @click="UserInput('tj')">选择答题人</el-button>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onBack">在线提交</el-button>
            </el-form-item>

        </el-row>

     -->


        <el-dialog title="承包商人员" :visible.sync="ListItem.dialogVisible" @close='closeDialog' width="90%" height="90%" top="0vh">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:400px;width:100%" frameborder="0"></iframe>
        </el-dialog>
    </div>
    <script type="text/javascript">
        app = new Vue({
            el: '#app',
            data: function () {
                return {
                    showExamQuestions: false,
                    showExamQuestions2: false,
                    id:'',
                    //TrainingCoursewareName:'维修安全',
                    ListItem: ListItem,
                    TrainingCoursewareNameList: [],//试题
                    TrainingCoursewareName:[],
                    answerPeople: "",
                    TestAnswer: [],//答案
                    cbS_ExamQuestionsUser:[],
                    DegreeOfDifficultyList: [{ key: '简单', value: '简单' },
                    { key: '一般', value: '一般' },
                    { key: '困难', value: '困难' },
                        { key: '极难', value: '极难' }],
                    Form: {
                        cbsCourseId: '',
                        testNo:'',
                        degreeOfDifficulty: '',
                        examinationDate: '',
                        judgmentNumber: '',
                        judgmentScore: '',
                        singleNumber: '',
                        singleScore: '',
                        multipleNumber: '',
                        multipleScore: '',
                        remarks: '',
                        cbS_ExamQuestionsDetail: [],
                        cbS_ExamQuestionsUser:[],
                    },
                    Form2: {
                        title:'',
                        cbsCourseId: '',
                        testNo: '',
                        degreeOfDifficulty: '',
                        examinationDate: '',
                        judgmentNumber: '',
                        judgmentScore: '',
                        singleNumber: '',
                        singleScore: '',
                        multipleNumber: '',
                        multipleScore: '',
                        remarks: '',
                        cbS_ExamQuestionsDetail: [],
                        cbS_ExamQuestionsUser: [],
                    },
                    formInline: {
                        model: {
                            TrainingCoursewareName: '',
                            TrainingCoursewareContentSummary: '',
                            TrainingCoursewareTypeName: '',
                            editor: '',
                            editorTime: ''
                        },
                        offset: 0,
                        limit: 10
                    },
                    //表单验证
                    rules: {
                        judgmentNumber: [
                            verification.NotNull,
                            verification.IsNum
                        ],
                        judgmentScore: [
                            verification.NotNull,
                            verification.IsNum
                        ],
                        singleNumber: [
                            verification.NotNull,
                            verification.IsNum
                        ],
                        singleScore: [
                            verification.NotNull,
                            verification.IsNum
                        ],
                        multipleNumber: [
                            verification.NotNull,
                            verification.IsNum
                        ],
                        multipleScore: [
                            verification.NotNull,
                            verification.IsNum
                        ],
                    },
                }
            }, created: function () {
            },
            mounted: function () {
                //this.TrainingCoursewareNameList = getDicDataAA('53');
                
                this.getClassList();
                this.Form.cbsCourseId = getUrlParam("cbsCourseId");
                //console.log(this.Form.cbsCourseId);
                this.GetPageData(1);
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                UserInput: function (val, id) { DialogShow(this, val, "ContractorPersonnelDirectoryList.html", id); },
                onBack: function () {

                    showMessage(msg.SubmitOK,'success')
                    parent.app.ListItem.dialogVisible = false;
                },
                //获取分页数据
                GetPageData: function (currentIndex) { //GetPageData(this, currentIndex, '/api/CBS_User/GetList') 
                    //var mythis = this;
                    //myAjax("post", mythis, '/api/CBS_ExamQuestionsDetail/GetList', { model: { cbSExamQuestionsId: 'E40E3895-50E6-494D-9F37-08D794AEF442' }, offset: 0, limit: 100 }, function (response) {
                    //    //this.TrainingCoursewareNameList = response.data.pageData;
                    //    var list = response.data.pageData;
                    //    for (var i = 0; i < list.length; i++) {
                    //        var tempI = i;
                            
                    //        myAjax("get", mythis, '/api/CBS_Questions/get?id=' + list[tempI].cbS_Questions.id, null, function (response) {
                    //            var ajaxModel = response.data;
                    //            list[tempI].cbS_Questions=ajaxModel;
                    //            //mythis.userFrom.sex = mythis.userFrom.sex + "";
                    //        }, false);
                    //    }
                    //    mythis.TrainingCoursewareNameList = list;

                    //    //console.log(response.data.pageData);
                    //}, false);
                },
                indexMethod: function (index) {
                    return (this.ListItem.currentPage - 1) * this.ListItem.pagesize + index + 1;
                },
                //初始化课件
                getClassList: function () {
                    var mythis = this;
                    myAjax("post", this, '/api/CBS_Course/GetList', { model: { createFactory: null }, offset: 0, limit: 100 }, function (response) {
                        mythis.TrainingCoursewareName = response.data.pageData;

                        //console.log(response.data.pageData);
                    }, false);
                },
                onShow: function () {
                    //this.Form.cbsCourseId = "";
                    this.Form.examinationDate = "";
                    this.Form.judgmentNumber = "";
                    this.Form.judgmentScore = "";
                    this.Form.singleNumber = "";
                    this.Form.singleScore = "";
                    this.Form.multipleNumber = "";
                    this.Form.multipleScore = "";
                    this.showExamQuestions = true;
                    
                },
                onClose: function () {
                    this.showExamQuestions = false;
                },
                onExamQuestions: function () {
                    if (this.showExamQuestions) {
                        var mythis = this;

                        this.$refs['ruleForm'].validate(function (valid) {
                            //验证通过
                            if (valid) {
                                if (mythis.Form.cbsCourseId == null || mythis.Form.cbsCourseId == "" || mythis.Form.cbsCourseId == undefined) {
                                    alert('请选择课件');
                                    return;
                                }
                                if (mythis.Form.examinationDate == null || mythis.Form.examinationDate == "" || mythis.Form.examinationDate == undefined) {
                                    alert('请选择考核日期');
                                    return;
                                }
                                if (mythis.Form.judgmentNumber == null || mythis.Form.judgmentNumber == "" || mythis.Form.judgmentNumber == undefined || parseInt(mythis.Form.judgmentNumber) <= 0) {
                                    alert('请输入判断题数量');
                                    return;
                                }
                                if (mythis.Form.judgmentScore == null || mythis.Form.judgmentScore == "" || mythis.Form.judgmentScore == undefined || parseFloat(mythis.Form.judgmentScore) <= 0) {
                                    alert('请输入判断题分数');
                                    return;
                                }
                                if (mythis.Form.singleNumber == null || mythis.Form.singleNumber == "" || mythis.Form.singleNumber == undefined || parseInt(mythis.Form.singleNumber) <= 0) {
                                    alert('请输入单选题数量');
                                    return;
                                }
                                if (mythis.Form.singleScore == null || mythis.Form.singleScore == "" || mythis.Form.singleScore == undefined || parseFloat(mythis.Form.singleScore) <= 0) {
                                    alert('请输入单选题分数');
                                    return;
                                }
                                if (mythis.Form.multipleNumber == null || mythis.Form.multipleNumber == "" || mythis.Form.multipleNumber == undefined || parseInt(mythis.Form.multipleNumber) <= 0) {
                                    alert('请输入多选题数量');
                                    return;
                                }
                                if (mythis.Form.multipleScore == null || mythis.Form.multipleScore == "" || mythis.Form.multipleScore == undefined || parseFloat(mythis.Form.multipleScore) <= 0) {
                                    alert('请输入多选题分数');
                                    return;
                                }
                                var tempSumScore = 0;
                                tempSumScore = (parseInt(mythis.Form.judgmentNumber) * parseFloat(mythis.Form.judgmentScore)) + (parseInt(mythis.Form.singleNumber) * parseFloat(mythis.Form.singleScore)) + (parseInt(mythis.Form.multipleNumber) * parseFloat(mythis.Form.multipleScore));
                                if (parseInt(tempSumScore) == 100) {
                                    mythis.Form.cbS_ExamQuestionsUser = mythis.cbS_ExamQuestionsUser;
                                    myAjax("post", mythis, '/api/CBS_ExamQuestions/Save', mythis.Form, function (response1) {
                                        var cbsQuestionsId = response1.data; //总体评估考核ID
                                        mythis.id = cbsQuestionsId;
                                        myAjax("post", mythis, '/api/CBS_ExamQuestionsDetail/GetList', { model: { cbSExamQuestionsId: cbsQuestionsId }, offset: 0, limit: 100 }, function (response) {
                                            //this.TrainingCoursewareNameList = response.data.pageData;
                                            var list = response.data.pageData;
                                            for (var i = 0; i < list.length; i++) {
                                                var tempI = i;

                                                myAjax("get", mythis, '/api/CBS_Questions/get?id=' + list[tempI].cbS_Questions.id, null, function (response) {
                                                    var ajaxModel = response.data;
                                                    list[tempI].cbS_Questions = ajaxModel;
                                                    //mythis.userFrom.sex = mythis.userFrom.sex + "";
                                                }, false);
                                            }
                                            mythis.TrainingCoursewareNameList = list;
                                            //form2
                                            
                                            
                                            for (var z = 0; z < mythis.TrainingCoursewareName.length; z++) {
                                                if (mythis.TrainingCoursewareName[z].id == mythis.Form.cbsCourseId) {
                                                    mythis.Form2.cbsCourseId = mythis.TrainingCoursewareName[z].trainingCoursewareName;
                                                }
                                                   
                                            }
                                            mythis.Form2.testNo = mythis.Form.testNo;
                                            mythis.Form2.degreeOfDifficulty = mythis.Form.degreeOfDifficulty;
                                            mythis.Form2.examinationDate = mythis.Form.examinationDate;
                                            mythis.Form2.judgmentNumber = mythis.Form.judgmentNumber;
                                            mythis.Form2.judgmentScore = mythis.Form.judgmentScore;
                                            mythis.Form2.singleNumber = mythis.Form.singleNumber;
                                            mythis.Form2.singleScore = mythis.Form.singleScore;
                                            mythis.Form2.multipleNumber = mythis.Form.multipleNumber;
                                            mythis.Form2.multipleScore = mythis.Form.multipleScore ;
                                            mythis.Form2.remarks = mythis.Form.remarks;
                                            mythis.Form2.title = "培训课件：" + mythis.Form2.cbsCourseId + mythis.Form2.degreeOfDifficulty + mythis.Form2.examinationDate + "试题";
                                            mythis.showExamQuestions2 = true;
                                            //console.log(response.data.pageData);
                                        }, false);
                                        mythis.showExamQuestions = false;


                                    }, false, function (response) {
                                        showMessage(response.message, 'error')
                                    });
                                } else {
                                    alert('总分数不等于100，当前总分' + tempSumScore);
                                    return;
                                }

                            } else {
                                //验证失败
                                return false;
                            }
                        });
                    } else {
                        alert("请先配置试卷");
                    }
                },
                onWord: function () {
                    if (this.id == null || this.id == "" || this.id == undefined) {
                        alert("请先生成试卷");
                    } else {
                        $("#export_word").wordExport("培训课件试题");
                    }
                },
            }
          
        });

    </script>
</body>
</html>